package com.ews.onlineexchange.controller;

import java.util.List;

import javax.enterprise.inject.Model;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import com.ews.onlineexchange.model.DataEntity;
import com.ews.onlineexchange.model.UndeterminedRoster;
import com.ews.onlineexchange.service.EntityQuery;

@Model
public class UndeterminedRosterList extends EntityQuery<UndeterminedRoster> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public UndeterminedRosterList() {
		setOrder("auditted desc,enteringDate DESC");
	}

	@Override
	protected List<Predicate> getRestrictions(CriteriaBuilder cb, Root<UndeterminedRoster> entity) {		
		List<Predicate> restrictions = super.getRestrictions(cb, entity);
		restrictions.add(cb.equal(entity.get("delFlag"), DataEntity.DEL_FLAG_NORMAL));
		
		return restrictions;
	}

	@Override
	protected void fetch(Root<UndeterminedRoster> entity) {
		// TODO Auto-generated method stub
		super.fetch(entity);
		entity.fetch("suppliers",JoinType.LEFT);
	}
	
}
